/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package org.jackysoft.entity;

import java.util.Map;







import org.dom4j.Element;
import org.jackysoft.bean.define.EntitySchemas;

/**
 * 
 */



public class ConditionNode extends AbstractNode {
	// ~ Instance fields
	// ////////////////////////////////////////////////////////

	/**
	 * 
	 */
	private static final long serialVersionUID = -1415374087504990728L;

	protected Map<String, String> args;

	/**
	 * The name field helps the editor identify the condition template used.
	 */
	protected String name;
	protected String type;
	protected boolean negate = false;

	// ~ Constructors
	// ///////////////////////////////////////////////////////////

	/**
     * 
     */
	public ConditionNode() {
	}

	public ConditionNode(Element element) {
		super(element);
	}

	@Override
	public Element asElement() {
		Element root = elementof("condition");
		attr(root, "id", id);
		attr(root, "name", this.name);
		attr(root, "type", this.type);
		attr(root, "negate", negate);
		addargs(root, this.args);
		return root;
	}

	// ~ Methods
	// ////////////////////////////////////////////////////////////////

	// 关联表和外键属性

	// ,inverseJoinColumns=

	// Map key元素的属性

	// Map 实体元素的属性

	// 级联属性

	
	
	
	public Map<String, String> getArgs() {
		return args;
	}

	public String getName() {
		return name;
	}

	public String getType() {
		return type;
	}

	@Override
	protected void init(Element root) {
		this.name = root.attributeValue("name");
		this.type = root.attributeValue("type");
		this.negate = Boolean.parseBoolean(root.attributeValue("negate"));
		this.args = args(root);
	}

	public boolean isNegate() {
		return negate;
	}

	/**
	 * 
	 */
	public void setArgs(Map<String, String> args) {
		this.args = args;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setNegate(boolean negate) {
		this.negate = negate;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public String tagName() {
		
		return "condition";
	}

}
